package com.watermeter.android.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.oa.android.R;
import com.watermeter.android.entry.jiaoFei;

import java.util.List;

/**
 * 缴费
 * Created by zouqh on 2016/5/23.
 */
public class JiaoFeiAdapter extends BaseAdapter {
    private Context context;
    private List<jiaoFei> rowses;

    public JiaoFeiAdapter(Context context, List<jiaoFei> rowses) {
        this.context = context;
        this.rowses = rowses;
    }

    @Override
    public int getCount() {
        return rowses.size();
    }

    @Override
    public Object getItem(int position) {
        return rowses.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHodler viewHodler;
        if (convertView == null) {
            viewHodler = new ViewHodler();
            convertView = LayoutInflater.from(context).inflate(R.layout.jiaofei_item, null);
            viewHodler.name = (TextView) convertView.findViewById(R.id.name);
            viewHodler.jfsj = (TextView) convertView.findViewById(R.id.jfsj);
            viewHodler.jfje = (TextView) convertView.findViewById(R.id.jfje);
            viewHodler.yue = (TextView) convertView.findViewById(R.id.yue);
            viewHodler.jyf = (TextView) convertView.findViewById(R.id.jyf);
            viewHodler.wsf = (TextView) convertView.findViewById(R.id.wsf);
            viewHodler.znj = (TextView) convertView.findViewById(R.id.znj);
            viewHodler.qtf = (TextView) convertView.findViewById(R.id.qtf);
            viewHodler.ljf = (TextView) convertView.findViewById(R.id.ljf);
            viewHodler.sf = (TextView) convertView.findViewById(R.id.sf);
            viewHodler.sfy = (TextView) convertView.findViewById(R.id.sfy);
            convertView.setTag(viewHodler);
        } else {
            viewHodler = (ViewHodler) convertView.getTag();
        }
        viewHodler.name.setText("客户姓名：" + rowses.get(position).getUSERNAME());
        viewHodler.jfsj.setText("缴费时间：" +rowses.get(position).getDT() );
        viewHodler.jfje.setText("缴费金额：" +rowses.get(position).getJYJE());
        viewHodler.yue.setText("余额：" +rowses.get(position).getPAYBCYE());
        viewHodler.jyf.setText("加压费：" +rowses.get(position).getSFJYF());
        viewHodler.wsf.setText("污水费：" +rowses.get(position).getSFWSCLF());
        viewHodler.znj.setText("滞纳金：" +rowses.get(position).getSFZNJ());
        viewHodler.qtf.setText("其他费用：" +rowses.get(position).getSFQT());
        viewHodler.ljf.setText("垃圾费：" +rowses.get(position).getSFLJCLF());
        viewHodler.sf.setText("水费：" +rowses.get(position).getSFSF());
        viewHodler.sfy.setText("收费员：" +rowses.get(position).getSFYNAME());

        return convertView;
    }

    class ViewHodler {
        TextView name;
        TextView jfsj;
        TextView jfje;
        TextView yue;
        TextView jyf;
        TextView wsf;
        TextView znj;
        TextView qtf;
        TextView ljf;
        TextView sf;
        TextView sfy;

    }
}
